#Does a teenager’s location in the United States increase ones chances of getting pregnant?
#Do counties with high teenage birthrates neighbor other counties with high teenage birthrates? #Do states level of sexual education impact Teenage Birth Rates? Is there a difference between rural and urban counties? regression - can predict teenage birth rates based on sexedu
Descriptive/Exploratory - without trying to model it spatial autocorrelation between of birthrates, if there are clusters try to make a hypothesis about why, could map it out
is religious beliefs, general school policies - clustering - local Moran I why there are these geospatial difference
#Relevant Definitions Pregnancy rate: refers to the rate of successful pregnancies. Birth Rate: number of live births per thousand of population per year
library(terra) |> suppressMessages()
## Warning: package 'terra' was built under R version 4.2.3
library(tmap)|> suppressMessages()
library(stringr) |> suppressMessages()
## Warning: package 'stringr' was built under R version 4.2.3
library(spdep) # package for spatial dependence
## Warning: package 'spdep' was built under R version 4.2.3
## Loading required package: spData
## Warning: package 'spData' was built under R version 4.2.3
## Loading required package: sf
## Warning: package 'sf' was built under R version 4.2.3
## Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(sf)|> suppressMessages()
library(dplyr)|> suppressMessages()
## Warning: package 'dplyr' was built under R version 4.2.3
library(tidyverse)|> suppressMessages()
## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'purrr' was built under R version 4.2.3
## Warning: package 'forcats' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
library(maps)|> suppressMessages()
## Warning: package 'maps' was built under R version 4.2.3
library(readxl)|> suppressMessages()
## Warning: package 'readxl' was built under R version 4.2.3
library(tigris)
## Warning: package 'tigris' was built under R version 4.2.3
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
##
## Attaching package: 'tigris'
## The following object is masked from 'package:terra':
##
## blocks
library(ggplot2)
library(ggpattern)
## Warning: package 'ggpattern' was built under R version 4.2.3
library(tidycensus)
## Warning: package 'tidycensus' was built under R version 4.2.3
options(tigris_use_cache = TRUE)
#Coding
# Load state and county data
#states_sf <- states(class = "sf")**
#counties_sf <- counties(class = "sf")**
states <- tigris::states(cb = TRUE, class = "sf")
## Retrieving data for the year 2021
counties <- tigris::counties(cb = TRUE, class = "sf")
## Retrieving data for the year 2022
# cb = TRUE for a low-resolution version for faster processing
# Visualize the map with state and county boundaries
#map <- mapview::mapview(states) + mapview::mapview(counties)**
#print(map)**
all_sf <- bind_rows(
mutate(states, type = "state"),
mutate(counties, type = "county")
)
mapview::mapview(all_sf)